package com.yaoyanshe.trialfield.network.http

import java.io.Serializable


data class SytResult<T>(
        val status: SytApiStatus,
        val data: T? = null,
        val msg: String = "",
        val code: Int = 0
) : Serializable {

    companion object {
        fun <T> success(data: T? = null): SytResult<T> {
            return SytResult(status = SytApiStatus.SUCCESS, data = data)
        }

        fun <T> error(msg: String = "", data: T? = null, code: Int = -1): SytResult<T> {
            return SytResult(status = SytApiStatus.ERROR, data = data, msg = msg, code = code)
        }

        fun <T> loading(): SytResult<T> {
            return SytResult(status = SytApiStatus.LOADING)
        }
    }
}

